function ajaxtoll(options){
    let xhr = new XMLHttpRequest()
    if(options.type.toLowerCase()=='get'){
        xhr.open("get",options.url+"?"+options.data);
        xhr.send();
    }
    else if(options.type.toLowerCase()=='post'){
        xhr.open("post",options.url);
        xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        xhr.send(options.data)
    }   
    xhr.onreadystatechange=function(){
        if(xhr.readyState==4&&xhr.status==200){
            options.success(xhr.responseText)
        }
    }
}

function getCookie(key){
    let cookie = document.cookie
    var arr = cookie.split('; ')
    for(let i=0;i<arr.length;i++){
        let item = arr[i].split('=')
        if(item[0]==key){
            return item[1]
        }
    }
}

function setCookie(key,value,day){
    let d = new Date()
    d.setDate(d.getDate()+day)
    document.cookie=key+'='+value+';expires='+d
}

function delCookie(key){
    setCookie(key,"",-1)
}
